﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Forms;
using System.Text;
using System.Drawing;


namespace HR60_PanelSoft.View
{

	public class ViewUtils
	{
		// 提示信息
		public static void showMessage(string msg)
		{
			MessageBox.Show(msg, "提示");
		}
		
		// 警告信息
		public static void showAlert(string msg)
		{
			MessageBox.Show(msg, "警告");
		}

		// 错误信息
		public static void showError(string msg)
		{
			MessageBox.Show(msg, "错误提醒");
		}

		// 打开文件窗体
		public static string showOpenFileDialog()
		{
			OpenFileDialog ofd = new OpenFileDialog();
			ofd.Multiselect = false;
			ofd.Filter = "JSON文件|*.json";
			DialogResult dr = ofd.ShowDialog();
			if (dr == DialogResult.OK)
			{
				return ofd.FileName;
			}
			return null;
		}

		// 保存文件窗体
		public static string showSaveFileDialog()
		{
			SaveFileDialog sfd = new SaveFileDialog();
			sfd.Filter = "JSON文件|*.json";
			DialogResult dr = sfd.ShowDialog();
			if (dr == DialogResult.OK)
			{
				return sfd.FileName;
			}
			return null;
		}
	}


    //public delegate void OnProcessHandler(int value);
    ///// <summary>
    ///// 通用进度条，切忌消除Topest bug
    ///// </summary>
    //public class CommonProgressBar : Form
    //{
    //    public static string ProgressBarTitle = string.Empty;
    //    private ProgressBar _S_bar = new ProgressBar();
    //    private int _value = -1;

    //    public int Value
    //    {
    //        set
    //        {
    //            if(value >= 10)
    //            {
    //                _S_bar.Value = _value = 10;
    //                System.Threading.Thread.Sleep(1000);
    //                this.Dispose();
    //            }
    //            else if (value < 0 )
    //            {
    //                _S_bar.Value = _value = 0;
    //            }
    //            else if (value < _value && _value >= 0)
    //            {
    //                _S_bar.Value = _value;
    //            }
    //        }
    //    }

    //    public CommonProgressBar(Control owner , string title)
    //    {
    //        /* Initialize Component */
    //        FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    //        Size = new Size(500,25); /* 设置窗口尺寸 */
    //        StartPosition = FormStartPosition.CenterParent;

    //        CheckForIllegalCrossThreadCalls = false;

    //        this.KeyDown += CommonProgressBar_KeyDown;
    //            /* ProgressBar abt */
    //        _S_bar.Dock = DockStyle.Fill;
    //        _S_bar.Maximum = 10;
    //        Owner = (Form)owner;
    //        TopMost = true;
    //        _S_bar.Visible = true;

    //        this.Controls.Add(_S_bar);

    //        //
    //        ProgressBarTitle = title;
            
    //    }

    //    void CommonProgressBar_KeyDown(object sender, KeyEventArgs e)
    //    {
    //        int i = -1;
    //        i = e.KeyValue;
    //        this.Value = i;
    //    }


    //    public void ShowBar(OnProcessHandler h)
    //    {
    //        this.ShowDialog();        
    //    }

        


    //}
}
